<div class="form">
<style type="text/css">
.sortable { list-style-type: none; margin: 20px 0; padding: 0;}
{if count($datalist)>40}
.sortable li { margin: 5px 5px 2px 0px;padding: 5px 10px;float: left;text-align: center;}
{else}
.sortable li { margin: 5px 12px 2px 0px;padding: 10px 5px;width:135px;text-align: center;}
{/if}
.sortable li span { position: absolute; margin-left: -1.3em; }

	
</style>

<div class="alert alert-warning">提示：鼠标拖动调整顺序。前台样式中心标签显示顺序缓存时间15分钟</div>

<ul class="sortable">
<?PHP
	foreach($datalist as $key=> $item)
	{
		echo '<li id="Tag_'.$item['Tag']['id'].'" class="ui-state-default">'.$item['Tag']['name'].'<small>('.$item['Tag']['priority'].')</small></li>';
	}
?>
</ul>
</div>

<script>
$(document).ready(function() {	
	$(".sortable").sortable({
		update: function(event, ui) {
			var orders = $(this).sortable('serialize');
			console.log(orders);
			$.post(
					'/admin/tags/sortfield/{{$tagmodel}}',
					orders
			);
		},
		placeholder: 'ui-state-highlight'
	});
	$(".sortable").disableSelection();
});
</script>
